package cn.qg.trade.service.qgGoodsTempStock;

import cn.qg.beans.pojo.QgGoodsTempStock;
import cn.qg.mapper.qggoodstempstock.QgGoodsTempStockMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * 11:34
 */
@Service
public class QgGoodsTempStockServiceImpl implements QgGoodsTempStockService{
    @Resource
    QgGoodsTempStockMapper qgGoodsTempStockMapper;
    @Override
    public void addQgGoodsTempStock(QgGoodsTempStock qgGoodsTempStock) throws Exception {
        qgGoodsTempStockMapper.insertQgGoodsTempStock(qgGoodsTempStock);
    }

    @Override
    public Integer getGoodsTempStockById(String goodsId, String userId) throws Exception {
        HashMap<String,Object> map = new HashMap<String, Object>();
        map.put("goodsId",goodsId);
        map.put("userId",userId);
        Integer num = qgGoodsTempStockMapper.getQgGoodsTempStockCountByMap(map);

        return num;
    }

    @Override
    public QgGoodsTempStock getGoodsTempStockBy(String goodsId, String userId) throws Exception {
        HashMap<String, Object> map = new HashMap<>();
        map.put("goodsId",goodsId);
        map.put("userId",userId);
        List<QgGoodsTempStock> list = qgGoodsTempStockMapper.getQgGoodsTempStockListByMap(map);

        return list.get(0);
    }
}
